import baseEntity from "./baseEntity";
import FileInfomation from "./FileInfomation";
export default class modelEntity extends baseEntity {
  constructor(options) {
    super(options);
    this.Files = options.Files;
    this.CreateTime = options.CreateTime;

    this.Remark = options.Remark;

    this.HasSubmit = options.HasSubmit;
    this.FileList = [];
    if (options.FileList) {
      options.FileList.forEach(x => {
        if (x) {
          this.FileList.push(new FileInfomation(x));
        }
      })
    }
    this.fileResult = options.fileResult ? options.fileResult : [];
    this.imgs = [];
    this.imgLoading = false;

  }
  getImgs() {
    return new Promise((resolve, reject) => {
      if (this.imgLoading) {
        resolve();
      } else {
        getApp().globalData.api.http_post_json(`${getApp().globalData.baseUrl}/api/oss/get`, this.FileList)
          .then(
            res => {
              this.imgLoading = true;
              this.imgs = res;
              console.log("imgs", res);
              resolve();
            }
          )
      }
    })
  }
  setFileStr() {
    let list = [];
    if (this.FileList) {
      this.FileList.forEach(x => list.push(x.GuidID));
    }

    if (this.fileResult) {
      this.fileResult.forEach(x => list.push(x.GuidID));
    }
    this.Files = list.join(',');
  }
}
